<?php

class heroModel extends Model{
    public function selectHero($page,$num){
        $sql = "select h.id,h.name,h.big_name,h.img,h.big_img,h.live,h.physics,h.magic,h.difficulty,t.type from hero h left join herotype t on h.type = t.id order by h.id limit $page,$num";
        return $this->link->selectByAll($sql);

    }
    public function selectHeroRows(){
        $sql = "select id from hero";
        return $this->link->count($sql);

    }
    public function deleteHero($id){
        $sql = "delete from h_passive where hid = $id";
        $p = $this->link->delete($sql);
        if(!$p){
            return "p";
        }
        $sql = "delete from h_q where hid = $id";
        $q = $this->link->delete($sql);
        if(!$q){
            return "q";
        }
        $sql = "delete from h_w where hid = $id";
        $w = $this->link->delete($sql);
       if(!$w){
            return "w";
        }
        $sql = "delete from h_e where hid = $id";
        $e = $this->link->delete($sql);
         if(!$e){
            return "e";
        }
        $sql = "delete from h_r where hid = $id";
        $r = $this->link->delete($sql);
        if(!$r){
            return "r";
        }
        $sql = "delete from h_skin where hid = $id";
        $skin = $this->link->delete($sql);
       if(!$skin){
            return "skin";
        }
        $sql = "delete from hero where id = $id";
        $hero = $this->link->delete($sql);
        if(!$hero){
            return $hero;
        }
        return true;
    }
}